<template>
  <div>
    <yd-navbar title="选择出行人员">
        <router-link :to="{path:'boutiquelinestep1',query: {}}" slot="left">
            <yd-navbar-back-icon></yd-navbar-back-icon>
        </router-link>
        <span slot="right" class="savebtn" @click="save(userobj)" ref="savebtn">完成</span>
    </yd-navbar>
    <div class="mui-content">
        <yd-cell-item>
            <yd-icon slot="icon" name="order" size=".42rem"></yd-icon>
            <span slot="left">添加人员</span>
        </yd-cell-item>
        <yd-search v-model="value1" :on-submit="submitHandler"></yd-search>
        <div class="usercontent" v-for="(tourlist, index) in tourist" :key="tourlist.index">
            <div class="userlist">
              <label><input name="" type="checkbox" value="" v-model="checkbox[index]" ref="checkboxID" @click="checkuser(tourlist, checkbox)" />{{tourlist.nickname}}</label>  
            </div>
        </div>
		</div>
	</div>
</template>

<script>
import database from 'hdc/database';
export default {
  name: 'boutiquelinefriend',
  components: {
    database
  },
  data() {
    return {
      value1: '',
      list: [
        {'label': '哈哈哈'},
        {'label': '嘿嘿黑'}
      ],
      checkbox: [],
      checkbox3: true,
      checkbox2: [
        {
          color: '',
          change: () => {
            this.$dialog.toast({mes: 'Say: 我关闭啦啦啦！'});
          }
        }
      ],

      tourist: [],
      backTourist: []
    }
  },
  mounted() {
    this.load();
    this.getFriendList();
  },
  methods: {
    load() {
    },
    submitHandler(value) {
      this.$dialog.toast({mes: `搜索：${value}`});
    },
    getFriendList() {
      // 获取添加的好友列表
      this.hdAjax({
        url: this.API.friendlist,
        success: resultData => {
          console.log('好友列表');
          console.log(resultData.result);
          for (const key in resultData.result) {
            if (resultData.result.hasOwnProperty(key)) {
              const element = resultData.result[key];
              element.forEach(list => {
                console.log(list);
                this.tourist.push(list);
                console.log(this.tourist);
              });
            }
          }
        }
      });
    },
    checkuser(tour, value) {
      console.log('888888', value);
      console.log(this.$refs.checkboxID.checked);
      // this.backTourist.push(tour);
    },
    change(value, isCheckAll) {
      console.log('222222');
      this.isCheckAll = isCheckAll;
    },
    save() {
      this.$router.push({path: 'boutiquelinestep1', query: {'id': this.product_id, 'g_manNum': this.g_manNum, 'g_childNum': this.g_childNum, 'datetime': this.datetime, 'tourist': this.backTourist}});
    },
    aaa() {
      console.log('aaaa');
    }
  }
}
</script>

<style>
.userlist {
  height: 40px;
  padding: 15px 20px;
  border-bottom:  1px solid #e8e8e8;
  size: 20px;
}
.userhead {
  height: 25px;
  padding-left: 10px;
  color: #cfcfcc;
  font-size: 20px;
  font-weight: bold;
  background-color: #f2f2f2;
  border-bottom:  1px solid #e8e8e8;
}
.mui-ios .mui-indexed-list-inner {
  width: calc(100% + 10px);
}
.mui-indexed-list-inner {
    margin: 0px;
    padding: 0px;
    overflow-y: auto;
    border: none;
}
.mui-indexed-list-alert.active {
    display: block;
}
.mui-indexed-list-alert {
    position: absolute;
    z-index: 20;
    background-color: rgba(0, 0, 0, 0.5);
    width: 80px;
    height: 80px;
    left: 50%;
    top: 50%;
    margin-left: -40px;
    margin-top: -40px;
    border-radius: 40px;
    text-align: center;
    line-height: 80px;
    font-size: 35px;
    color: #fff;
    display: none;
    -webkit-transition: .2s;
}

</style>
